package cn.hxzy.kaoshi.controller;


import cn.hxzy.common.response.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 考试成绩记录表 前端控制器
 * </p>
 *
 * @author tyqw
 * @since 2024-12-13
 */
@RestController
@RequestMapping("/sysExamResults")
public class SysExamResultsController {
    @Autowired
    private cn.hxzy.kaoshi.service.ISysExamResultsService sysExamResultsService;

    @RequestMapping("/add")
    public R add(cn.hxzy.kaoshi.entity.SysExamResults sysExamResults) {
        sysExamResultsService.add(sysExamResults);
        return R.success("考试成绩录入成功");
    }

    //根据学生id查询考试记录
    @GetMapping("/kaoshijilu/{userid}/{usertype}")
    public R findAllExamResults(@PathVariable("userid") Long userid, @PathVariable("usertype") Integer usertype) {
        System.out.println(userid + "==" + usertype);
        List<Map> list = sysExamResultsService.findAllExamResults(userid, usertype);
        return R.success(list);
    }


    @GetMapping("/kaoshi/{userid}/{examId}")
    public R isTimeWithinRange(@PathVariable("userid") String userid, @PathVariable("examId") String examId) {
        return R.success(sysExamResultsService.isTimeWithinRange(userid, examId));
    }
}
